package com.prs.crm.dao.taskmanager.impl;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;

import com.prs.crm.context.AppContext;
import com.prs.crm.dao.impl.BaseDaoImpl;
import com.prs.crm.dao.taskmanager.DeptTaskResultDao;
import com.prs.crm.domain.taskmanager.DeptTaskResult;
import com.prs.crm.domain.taskmanager.PersonalTaskResult;

public class DeptTaskResultDaoImpl extends BaseDaoImpl<DeptTaskResult>	implements DeptTaskResultDao{

	@SuppressWarnings("unchecked")
	@Override
	public List<DeptTaskResult> getAllDeptTaskResult() {
		Criteria criteria=this.getSession().createCriteria(DeptTaskResult.class);
		return criteria.list();
	}

	@Override
	public DeptTaskResult getDeptTaskResult(String type) {
		Criteria criteria=this.getSession().createCriteria(DeptTaskResult.class);
		criteria.add(Restrictions.eq("type", AppContext.getAccountContext().getUser().getDept().getName()));
		List result=criteria.list();
		if(result==null || result.size()==0){
			return null;
		}
		return (DeptTaskResult) criteria.list().get(0);
	}
}
